package com.cn.sl.server.config.websocket

import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.context.event.EventListener
import org.springframework.stereotype.Component
import org.springframework.web.bind.annotation.ControllerAdvice
import org.springframework.web.socket.messaging.SessionConnectedEvent
import org.springframework.web.socket.messaging.SessionDisconnectEvent

/**
 * @author 阮雪峰
 */
@Component
class WebSocketEventListener {
    val log: Logger = LoggerFactory.getLogger(ControllerAdvice::class.java)

    @EventListener
    fun handleConnectListener(event: SessionConnectedEvent) {
        log.info("[ws-connected] socket connect: {}", event.message)
    }

    @EventListener
    fun handleDisconnectListener(event: SessionDisconnectEvent) {
        log.info("[ws-disconnect] socket disconnect: {}", event.message)
    }
}
